import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeRequiredRule} from '../../utils';

const label = '日期区间';
const name = 'a-range-picker';

export default {
  icon: 'icon-date',
  label,
  name,
  rule({t}) {
    return {
      type: name,
      field: uniqueId(),
      title: t('components.dateRange.name'),
      info: '',
      $required: false,
      props: {
        mode: 'date',
      },
    };
  },
  props(_, {t}) {
    return localeProps(t, name + '.props', [
      makeRequiredRule(),
      {
        type: 'switch',
        title: '显示时间',
        field: 'disabled'
      },
      {
        type: 'select',
        title: '显示时间',
        field: 'mode',
        options: [
          {label: 'week', value: 'week'},
          {label: 'month', value: 'month'},
          {label: 'year', value: 'year'},
          {label: 'quarter', value: 'quarter'},
          {label: 'date', value: 'date'}
        ]
      },
      {
        type: 'switch',
        field: 'showTime',
        title: '显示时间',
        value: false,
      },
      {
        type: 'switch',
        title: '是否允许清除',
        field: 'allowClear',
        value: true
      },
      {
        type: 'input',
        title: '提示文案',
        field: 'placeholder'
      },
      {
        type: 'Struct',
        title: '当前时间日期选择器特有的选项',
        field: 'pickerOptions',
        props: {defaultValue: {}}
      },
      {
        type: 'switch',
        title: '是否禁止键盘输入日期',
        field: 'disabledInput',
        value: false
      },
      {
        type: 'input',
        title: '展示日期的格式，参考字符串解析格式',
        field: 'format'
      },
      {
        type: 'input',
        title: '值的格式',
        field: 'valueFormat'
      },
      {
        type: 'input',
        title: '范围选择器输入框内的分割符号',
        field: 'separator'
      }
    ]);
  }
};
